<template>
  <div class="daksh-container">
    <div class="main">
      <div class="panel">
        <!-- 左侧库房区域 -->
        <div class="left-section">
          <div class="section-header">
            <h3>库房信息</h3>
          </div>
          <div class="section-content">
            <div class="list-container" v-if="warehouses.length > 0">
              <div
                v-for="warehouse in warehouses"
                :key="warehouse.id"
                class="list-item"
              >
                <div
                  class="item-header"
                  @click="handleWarehouseClick(warehouse)"
                  :class="{ 'item-selected': warehouse.selected }"
                >
                  <span>
                    <a-icon type="bank" style="margin-right: 8px" />
                    {{ warehouse.name }}
                  </span>
                  <span class="arrow">
                    <a-icon :type="warehouse.expanded ? 'down' : 'right'" />
                  </span>
                </div>
                <div v-if="warehouse.expanded" class="sub-list">
                  <div
                    v-for="area in warehouse.areas"
                    :key="area.id"
                    class="list-item"
                  >
                    <div
                      class="item-header"
                      @click="toggleArea(area, warehouse)"
                      :class="{ 'item-selected': area.selected }"
                    >
                      <span>
                        <a-icon type="folder" style="margin-right: 8px" />
                        {{ area.name }}
                      </span>
                      <span class="arrow">
                        <a-icon :type="area.expanded ? 'down' : 'right'" />
                      </span>
                    </div>
                    <div v-if="area.expanded" class="sub-list">
                      <div
                        v-for="cabinet in area.cabinets"
                        :key="cabinet.id"
                        class="list-item"
                      >
                        <div
                          class="item-header"
                          @click="selectCabinet(cabinet, area, warehouse)"
                          :class="{ 'item-selected': cabinet.selected }"
                        >
                          <span>
                            <a-icon type="database" style="margin-right: 8px" />
                            {{ cabinet.name }}
                          </span>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <div v-else class="empty-placeholder">请选择库房</div>
          </div>
        </div>

        <!-- 右侧档案信息区域 -->
        <div class="right-section">
          <div class="section-header">
            <h3>档案信息</h3>
          </div>
          <!-- 添加搜索区域 -->
          <div class="search-section" :class="{'search-expanded': searchExpanded}">
            <div class="search-content">
              <a-form layout="inline">
                <a-form-item label="档案名称">
                  <a-input
                    v-model="archiveQuery.damc"
                    placeholder="请输入档案名称"
                    allowClear
                    @pressEnter="handleSearch"
                    style="width: 150px"
                  />
                </a-form-item>
                <a-form-item label="档案编号">
                  <a-input
                    v-model="archiveQuery.bzdah"
                    placeholder="请输入档案编号"
                    allowClear
                    @pressEnter="handleSearch"
                    style="width: 150px"
                  />
                </a-form-item>
                <a-form-item label="档案类别">
                  <a-select
                    v-model="archiveQuery.dalx"
                    placeholder="请选择档案类别"
                    allowClear
                    style="width: 150px"
                  >
                    <a-select-option
                      v-for="item in archiveTypeOptions"
                      :key="item.value"
                      :value="item.value"
                    >
                      {{ item.label }}
                    </a-select-option>
                  </a-select>
                </a-form-item>
                <a-form-item label="档案状态">
                  <a-select
                    v-model="archiveQuery.dazt"
                    placeholder="请选择档案状态"
                    allowClear
                    style="width: 150px"
                  >
                    <a-select-option
                      v-for="item in archiveStatusOptions"
                      :key="item.value"
                      :value="item.value"
                    >
                      {{ item.label }}
                    </a-select-option>
                  </a-select>
                </a-form-item>
                <a-form-item>
                  <a-button type="primary" icon="search" @click="handleSearch">查询</a-button>
                  <a-button style="margin-left: 8px" @click="resetSearch">重置</a-button>
                </a-form-item>
              </a-form>
            </div>
            <div class="search-expander" @click="toggleSearchExpand">
              <a-icon :type="searchExpanded ? 'up' : 'down'" />
              <span>{{ searchExpanded ? '收起' : '展开' }}</span>
            </div>
          </div>
          <div class="right-section-content">
            <div class="example-spin" v-if="archiveSpinning">
              <a-spin
                :spinning="archiveSpinning"
                :delay="500"
                tip="档案加载中..."
              ></a-spin>
            </div>
            <!-- 档案详细信息将在这里显示 -->
            <div class="archive-list">
              <a-archive
                :archives="archivesList"
                @viewArchive="handleViewArchive"
              />
              <div v-if="archiveListEmpty" class="empty-placeholder">
                <a-empty description="暂无档案记录" />
              </div>
            </div>
            <div class="pagination-container">
              <a-pagination
                :current="archiveQuery.page"
                :page-size="archiveQuery.pageSize"
                :total="archiveTotal"
                :pageSizeOptions="pageSizeOptions"
                :defaultPageSize="100"
                showSizeChanger
                showQuickJumper
                @change="handleArchivePageChange"
                @showSizeChange="handleArchivePageSizeChange"
              />
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
import { Component, Vue } from 'vue-property-decorator';

import moment from 'moment';
import YSAPI from '../apis/ys';
import archive from '../components/archive/archive.vue';
import { getQueryParams, getDictionaryParams } from '../utils/util';

interface Cabinet {
  id: number;
  name: string;
  selected?: boolean;
}

interface Area {
  id: number;
  name: string;
  expanded: boolean;
  cabinets: Cabinet[];
  selected?: boolean;
}

interface Warehouse {
  id: number;
  name: string;
  expanded: boolean;
  areas: Area[];
  selected?: boolean;
}

interface Archive {
  id: number;
  name: string;
  status: string;
  statusText: string;
  expirationDate: string;
  summary: string;
  tags: string[];
}

interface StatusMap {
  [key: string]: string;
}

interface ArchiveQuery {
  page: number;
  pageSize?: number;
  damc?: string;
  bzdah?: string;
  dalx?: undefined;
  dazt?: undefined;
}

@Component({
  name: 'Daksh',
  components: {
    AArchive: archive,
  },
})
export default class Daksh extends Vue {
  // 库房列表
  warehouses: Warehouse[] = [];

  // 选中的库房
  selectedWarehouse: Warehouse | null = null;

  // 选中的区域
  selectedArea: Area | null = null;

  // 选中的档案柜
  selectedCabinet: Cabinet | null = null;

  // 档案列表
  archivesList: Archive[] = [];

  // 档案状态映射
  statusMap: StatusMap = {
    正常: 'normal',
    过期: 'expire',
    销毁: 'destroy',
    借阅中: 'borrowing',
  };

  // 档案查询条件
  archiveQuery: ArchiveQuery = {
    page: 0,
    pageSize: 100,
    damc: '',
    bzdah: '',
    dalx: undefined,
    dazt: undefined,
  };

  // 档案总数量
  archiveTotal: number = 0;

  // 档案列表是否为空
  archiveListEmpty: boolean = false;

  // 档案加载中
  archiveSpinning: boolean = false;

  // 分页大小选项
  pageSizeOptions: string[] = ['100', '200', '300', '400', '500'];

  // 档案类别选项
  archiveTypeOptions = [];

  // 档案状态选项
  archiveStatusOptions = [
    { label: '正常', value: 'option1' },
    { label: '过期', value: 'option2' },
    { label: '销毁', value: 'option3' },
    { label: '借阅中', value: 'option4' },
  ];

  // 搜索展开状态
  searchExpanded: boolean = false;

  // 处理库房点击事件
  handleWarehouseClick(warehouse: Warehouse) {
    this.toggleWarehouse(warehouse);
  }

  /**
   * 切换库房
   * @param warehouse 库房
   */
  async toggleWarehouse(warehouse: Warehouse) {
    warehouse.expanded = !warehouse.expanded;
    this.clearAllSelections();
    warehouse.selected = true;
    this.selectedWarehouse = warehouse;
    this.selectedArea = null;
    this.selectedCabinet = null;

    // 获取区域列表
    await this.getAreaList(warehouse);

    await this.getArchiveList(
      this.selectedWarehouse,
      this.selectedArea,
      this.selectedCabinet,
    );
  }

  /**
   * 切换区域
   * @param area 区域
   * @param warehouse 库房
   */
  async toggleArea(area: Area, warehouse: Warehouse) {
    area.expanded = !area.expanded;
    this.clearAllSelections();
    warehouse.selected = true;
    area.selected = true;
    this.selectedWarehouse = warehouse;
    this.selectedArea = area;
    this.selectedCabinet = null;

    // 获取档案柜列表
    await this.getCabinetList(area, warehouse);
    await this.getArchiveList(
      this.selectedWarehouse,
      this.selectedArea,
      this.selectedCabinet,
    );
  }

  /**
   * 选择档案柜
   * @param cabinet 档案柜
   * @param area 区域
   * @param warehouse 库房
   */
  async selectCabinet(cabinet: Cabinet, area: Area, warehouse: Warehouse) {
    this.clearAllSelections();
    warehouse.selected = true;
    area.selected = true;
    cabinet.selected = true;
    this.selectedWarehouse = warehouse;
    this.selectedArea = area;
    this.selectedCabinet = cabinet;

    await this.getArchiveList(
      this.selectedWarehouse,
      this.selectedArea,
      this.selectedCabinet,
    );
  }

  /**
   * 清除所有选中状态
   */
  clearAllSelections() {
    this.warehouses.forEach((warehouse) => {
      warehouse.selected = false;
      warehouse.areas.forEach((area) => {
        area.selected = false;
        area.cabinets.forEach((cabinet) => {
          cabinet.selected = false;
        });
      });
    });
  }

  /**
   * 获取库房列表
   */
  getWarehouseList() {
    // 获取库房列表 查询代码：dakfxx 查询数量：100
    const queryParams = getQueryParams('dakfxx', 0, 100);
    YSAPI.getList(queryParams).then(({ errcode, data }) => {
      if (errcode === 0) {
        // 将库房列表转换为树形结构
        this.warehouses = data.content.map((item: any) => ({
          id: item.data.id,
          name: item.data.kfmc,
          expanded: false,
          areas: [],
        }));

        console.log(
          '🚀 ~ Daksh ~ YSAPI.getList ~ warehouses:',
          this.warehouses,
        );
        if (this.warehouses.length < 0)
          return this.$message.error('库房列表为空');
        // 获取区域列表
        this.toggleWarehouse(this.warehouses[0]);
      }
    });
  }

  /**
   * 获取区域列表
   * @param warehouseId 库房ID
   */
  async getAreaList(warehouse: Warehouse) {
    console.log('🚀 ~ Daksh ~ getAreaList ~ warehouseId:', warehouse.id);
    // 获取区域列表 查询代码：dakfxx 查询数量：100
    const queryParams = getQueryParams('daqbh', 0, 100, [
      {
        queryFilterType: 'Eq',
        propertyCode: 'qglk',
        propertyType: 9,
        propertyValue: warehouse.id,
      },
    ]);
    // 获取区域列表
    const { errcode, data } = await YSAPI.getList(queryParams);
    console.log('🚀 ~ Daksh ~ getAreaList ~ data:', data);
    if (errcode === 0 && data.content.length > 0) {
      // 找到对应的库房
      if (warehouse) {
        // 将区域列表转换为树形结构
        warehouse.areas = data.content.map((item: any) => ({
          id: item.data.id,
          name: item.data.daqmc,
          expanded: false,
          cabinets: [],
        }));
        console.log(
          '🚀 ~ Daksh ~ getAreaList ~ this.warehouses:',
          this.warehouses,
        );
      } else console.warn(`未找到ID为 ${warehouse.id} 的库房`);
    } else this.$message.error(`${warehouse.name} 没有区域`);
    return [];
  }

  /**
   * 获取档案柜列表
   * @param areaId 区域ID
   */
  async getCabinetList(area: Area, warehouse: Warehouse) {
    console.log('🚀 ~ Daksh ~ getCabinetList ~ areaId:', area.id);
    // 获取档案柜列表 查询代码：dakfxx 查询数量：100
    const queryParams = getQueryParams('dagxxgl', 0, 100, [
      {
        queryFilterType: 'Eq',
        propertyCode: 'qglk',
        propertyType: 9,
        propertyValue: warehouse.id,
      },
      {
        queryFilterType: 'Eq',
        propertyCode: 'daqgl',
        propertyType: 9,
        propertyValue: area.id,
      },
    ]);
    // 获取档案柜列表
    const { errcode, data } = await YSAPI.getList(queryParams);
    console.log('🚀 ~ Daksh ~ getCabinetList ~ data:', data);
    if (errcode === 0 && data.content.length > 0) {
      // 找到对应的区域
      if (area) {
        // 将档案柜列表转换为树形结构
        area.cabinets = data.content.map((item: any) => ({
          id: item.data.id,
          name: item.data.dagmc,
        }));
      }
      console.log(
        '🚀 ~ Daksh ~ getCabinetList ~ this.warehouses:',
        this.warehouses,
      );
    } else this.$message.error(`${area.name} 没有档案柜`);
  }

  /**
   * 档案列表分页改变
   * @param page 页码
   * @param pageSize 分页大小
   */
  handleArchivePageChange(page: number, pageSize: number) {
    console.log('🚀 ~ Daksh ~ handleArchivePageChange ~ page:', page);
    console.log('🚀 ~ Daksh ~ handleArchivePageChange ~ pageSize:', pageSize);
    this.archiveQuery.page = page - 1;
    this.archiveQuery.pageSize = pageSize;
    this.getArchiveList(
      this.selectedWarehouse,
      this.selectedArea,
      this.selectedCabinet,
    );
  }

  /**
   * 档案列表分页大小改变
   * @param pageSize 分页大小
   */
  handleArchivePageSizeChange(page: number, pageSize: number) {
    console.log(
      '🚀 ~ Daksh ~ handleArchivePageSizeChange ~ pageSize:',
      pageSize,
    );
    this.archiveQuery.page = 0;
    this.archiveQuery.pageSize = pageSize;
    this.getArchiveList(
      this.selectedWarehouse,
      this.selectedArea,
      this.selectedCabinet,
    );
  }

  /**
   * 获取档案列表
   * @param warehouse 库房
   * @param area 区域
   * @param cabinet 档案柜
   */
  async getArchiveList(warehouse: Warehouse, area: Area, cabinet: Cabinet) {
    this.archiveSpinning = true;
    try {
      // 构建基本查询条件
      const condition = this.buildArchiveQueryCondition(
        warehouse,
        area,
        cabinet,
      );

      // 添加搜索条件
      this.appendSearchConditions(condition);

      // 获取分页信息并执行查询
      const { page, pageSize } = this.archiveQuery;
      const queryParams = getQueryParams('zzdanxx', page, pageSize, condition, {
        showTotal: true,
      });

      const { errcode, data } = await YSAPI.getList(queryParams);

      if (errcode === 0) {
        this.processArchiveData(data);
      } else {
        this.$message.error('获取档案列表失败');
      }
    } catch (error) {
      console.error('获取档案列表出错:', error);
      this.$message.error('获取档案列表失败');
    } finally {
      this.archiveSpinning = false;
    }
  }

  /**
   * 构建档案查询的基本条件
   * @param warehouse 库房
   * @param area 区域
   * @param cabinet 档案柜
   * @returns 档案查询条件
   */
  private buildArchiveQueryCondition(
    warehouse?: Warehouse,
    area?: Area,
    cabinet?: Cabinet,
  ) {
    return [
      {
        queryFilterType: 'Eq',
        propertyCode: 'ssdak', // 所属档案库（库房）
        propertyType: 9,
        propertyValue: warehouse?.id || '',
      },
      {
        queryFilterType: 'Eq',
        propertyCode: 'dassq', // 档案所属区
        propertyType: 9,
        propertyValue: area?.id || '',
      },
      {
        queryFilterType: 'Eq',
        propertyCode: 'dassg', // 档案所属柜
        propertyType: 9,
        propertyValue: cabinet?.id || '',
      },
    ].filter((item) => item.propertyValue); // 过滤掉空值条件
  }

  /**
   * 添加高级搜索条件
   * @param condition 档案查询条件
   */
  private appendSearchConditions(condition: any[]) {
    // 搜索条件配置
    const searchConfig = [
      { key: 'damc', code: 'damc', type: 0, filter: 'Like' },
      { key: 'bzdah', code: 'dabh', type: 1, filter: 'Like' },
      { key: 'dalx', code: 'dalx', type: 14, filter: 'Eq' },
      { key: 'dazt', code: 'ddzt_dxk', type: 12, filter: 'Eq', select: true },
    ];

    // 批量处理搜索条件
    searchConfig.forEach((config) => {
      const value = this.archiveQuery[config.key];
      if (value) {
        condition.push({
          queryFilterType: config.filter,
          propertyCode: config.code,
          propertyType: config.type,
          propertyValue:
            config.select ? this.getSelectValue(value) : value,
        });
      }
    });
  }

  /**
   * 获取选择值
   * @param value 选择值
   * @returns 选择值
   */
  private getSelectValue(value: string) {
    const result = this.archiveStatusOptions.find(
      (item) => item.value === value,
    );
    return `[{"key":"${result?.value}","value":"${result?.label}"}]`;
  }

  /**
   * 处理档案数据
   * @param data 档案数据
   */
  private processArchiveData(data: any) {
    if (!data?.content?.length) {
      this.archivesList = [];
      this.archiveListEmpty = true;
      this.archiveTotal = 0;
      return;
    }

    this.archivesList = data.content.map((item: any) => ({
      id: item.data.id,
      name: item.data.damc,
      status: this.statusMap[item.data.ddzt_dxk] || 'normal',
      statusText: item.data.ddzt_dxk || '正常',
      expirationDate: item.data.dasxrq_rq
        ? moment(item.data.dasxrq_rq).format('YYYY-MM-DD')
        : '-',
      summary: item.data.wdgy_cwb || '暂无概要',
      tags: item.data.dalx ? item.data.dalx.split(';') : ['-'],
      number: item.data.bzdah,
    }));

    this.archiveTotal = Number(data.totalElements) || 0;
    this.archiveListEmpty = this.archivesList.length === 0;
  }

  /**
   * 查看档案
   * @param item 档案
   */
  handleViewArchive(item: Archive) {
    console.log('🚀 ~ Daksh ~ handleViewArchive ~ item:', item);
  }

  /**
   * 搜索档案
   */
  handleSearch() {
    this.archiveQuery.page = 0;
    this.getArchiveList(
      this.selectedWarehouse,
      this.selectedArea,
      this.selectedCabinet,
    );
  }

  /**
   * 重置搜索条件
   */
  resetSearch() {
    this.archiveQuery = {
      damc: '',
      bzdah: '',
      dalx: undefined,
      dazt: undefined,
      page: 0,
      pageSize: 100,
    };
    this.handleSearch();
  }

  /**
   * 获取字典类型数据
   */
  getDictionaryData() {
    YSAPI.skipQueryList(getDictionaryParams('danlx', 0, 100)).then(
      ({ errcode, data }) => {
        if (errcode === 0) {
          this.archiveTypeOptions = data.content.map((item: any) => ({
            label: item.data.lxmc,
            value: item.data.lxmc,
          }));
        }
      },
    );
  }

  /**
   * 切换搜索展开状态
   */
  toggleSearchExpand() {
    this.searchExpanded = !this.searchExpanded;
  }

  created() {
    // 获取库房列表
    this.getWarehouseList();
    // 获取字典类型数据
    this.getDictionaryData();
  }
}
</script>

<style lang="less" scoped>
.daksh-container {
  height: 100%;
  padding: 12px;
  background: #f1f2f6;
  background-image: linear-gradient(to bottom right, #f1f2f6, #e6f7ff);

  .main {
    height: 100%;
    background: #fff;
    padding: 12px;
    position: relative;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    position: relative;
    overflow: hidden;

    &::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      height: 4px;
      background: linear-gradient(to right, #1890ff, #52c41a);
    }
  }

  .panel {
    display: flex;
    height: 100%;
    gap: 12px;

    .left-section,
    .right-section {
      background: #fafafa;
      border-radius: 6px;
      border: 1px solid #eee;
      overflow: hidden;
      display: flex;
      flex-direction: column;
      box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
      transition: all 0.3s ease;

      &:hover {
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
      }
    }

    .left-section {
      flex: 1;
      max-width: 18%;
    }

    .right-section {
      flex: 2;
    }

    .section-header {
      padding: 12px 16px;
      background: linear-gradient(to right, #f5f5f5, #e8f4ff);
      border-bottom: 1px solid #eee;
      position: relative;

      h3 {
        margin: 0;
        font-size: 16px;
        color: #333;
        font-weight: 600;
        display: flex;
        align-items: center;

        &::before {
          content: '';
          display: inline-block;
          width: 4px;
          height: 16px;
          background: #1890ff;
          margin-right: 8px;
          border-radius: 2px;
        }
      }
    }

    .section-content {
      padding: 16px;
      flex: 1;
      position: relative;
    }

    .right-section-content {
      flex: 1;
      position: relative;
    }

    .empty-placeholder {
      color: #999;
      text-align: center;
      padding: 40px 0;
      font-size: 14px;
      display: flex;
      justify-content: center;
      align-items: center;
      width: 100%;
      height: 100%;
    }

    .archive-info {
      padding: 16px;
      background: #fff;
      border-radius: 6px;
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);

      h4 {
        margin-top: 0;
        margin-bottom: 16px;
        color: #333;
        font-weight: 600;
        border-bottom: 1px solid #eee;
        padding-bottom: 8px;
      }

      p {
        margin-bottom: 8px;
        color: #666;
      }
    }
  }

  .list-container {
    .list-item {
      margin-bottom: 4px;

      .item-header {
        padding: 8px 12px;
        background: #f5f5f5;
        border-radius: 4px;
        cursor: pointer;
        display: flex;
        justify-content: space-between;
        align-items: center;
        transition: all 0.2s ease;
        border-left: 3px solid transparent;

        &:hover {
          background: #e8e8e8;
          transform: translateX(2px);
        }

        &.item-selected {
          background: #e6f7ff;
          border-left: 3px solid #1890ff;
          color: #1890ff;
          font-weight: 500;
          box-shadow: 0 1px 3px rgba(24, 144, 255, 0.15);
        }
      }

      .sub-list {
        padding-left: 16px;
        margin-top: 4px;
      }

      .arrow {
        font-size: 12px;
        color: #666;
      }
    }
  }

  .archive-list {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 50px;
    padding: 16px;
    padding-bottom: 0;
    overflow-y: auto;
    background: url('');
    background-size: 20px 20px;
    background-position: center;
    background-attachment: fixed;

    &::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      height: 100%;
      background: rgba(255, 255, 255, 0.92);
      z-index: -1;
    }

    &::-webkit-scrollbar {
      width: 6px;
    }

    &::-webkit-scrollbar-thumb {
      background-color: #d9d9d9;
      border-radius: 3px;

      &:hover {
        background-color: #bfbfbf;
      }
    }
  }

  .empty-placeholder {
    color: #999;
    text-align: center;
    padding: 40px 0;
    font-size: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    flex-direction: column;
    position: relative;

    &::after {
      content: '暂无档案信息';
      font-size: 24px;
      color: rgba(0, 0, 0, 0.03);
      position: absolute;
      transform: rotate(-45deg);
      white-space: nowrap;
      z-index: -1;
    }

    .ant-empty {
      margin: 10px 0;

      .ant-empty-image {
        opacity: 0.8;
      }
    }
  }

  .pagination-container {
    position: absolute;
    bottom: 0;
    padding: 8px 0;
    border-radius: 4px;
    z-index: 1;
    left: 0;
    right: 10px;
    display: flex;
    justify-content: flex-end;
  }

  .example-spin {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    background-color: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(2px);
  }

  .search-section {
    padding: 12px 16px;
    background: #f8f8f8;
    border-bottom: 1px solid #eee;
    position: relative;
    
    .search-content {
      max-height: 96px; /* 控制两行的高度 */
      overflow: hidden;
      transition: max-height 0.3s ease;
    }
    
    &.search-expanded .search-content {
      max-height: 300px; /* 展开后的最大高度 */
      overflow-y: auto;
      
      &::-webkit-scrollbar {
        width: 4px;
      }
      
      &::-webkit-scrollbar-thumb {
        background-color: #d9d9d9;
        border-radius: 2px;
      }
    }
    
    .search-expander {
      position: absolute;
      bottom: -12px;
      left: 50%;
      transform: translateX(-50%);
      background: #f8f8f8;
      border: 1px solid #eee;
      border-radius: 12px;
      padding: 2px 12px;
      font-size: 12px;
      color: #1890ff;
      cursor: pointer;
      z-index: 2;
      box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
      transition: all 0.2s ease;
      
      &:hover {
        color: #40a9ff;
        box-shadow: 0 2px 6px rgba(24, 144, 255, 0.2);
      }
      
      .anticon {
        margin-right: 4px;
        font-size: 10px;
      }
    }
    
    .ant-form-item {
      margin-bottom: 12px;
      margin-right: 16px;
    }
    
    .ant-input {
      width: 150px;
    }
  }
}
</style>
